home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / src / pvmdabuf.c < prev    next >
C/C++ Source or Header  |  1997-07-22  |  2KB  |  110 lines

  1.  
  2. static char rcsid[] =
  3.     "$Id: pvmdabuf.c,v 1.4 1997/06/25 22:09:20 pvmsrc Exp $";
  4.  
  5. /*
  6.  *         PVM version 3.4:  Parallel Virtual Machine System
  7.  *               University of Tennessee, Knoxville TN.
  8.  *           Oak Ridge National Laboratory, Oak Ridge TN.
  9.  *                   Emory University, Atlanta GA.
  10.  *      Authors:  J. J. Dongarra, G. E. Fagg, M. Fischer
  11.  *          G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
  12.  *         P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
  13.  *                   (C) 1997 All Rights Reserved
  14.  *
  15.  *                              NOTICE
  16.  *
  17.  * Permission to use, copy, modify, and distribute this software and
  18.  * its documentation for any purpose and without fee is hereby granted
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both the copyright notice and this permission notice appear in
  21.  * supporting documentation.
  22.  *
  23.  * Neither the Institutions (Emory University, Oak Ridge National
  24.  * Laboratory, and University of Tennessee) nor the Authors make any
  25.  * representations about the suitability of this software for any
  26.  * purpose.  This software is provided ``as is'' without express or
  27.  * implied warranty.
  28.  *
  29.  * PVM version 3 was funded in part by the U.S. Department of Energy,
  30.  * the National Science Foundation and the State of Tennessee.
  31.  */
  32.  
  33. /*
  34.  *    pvmdabuf.c
  35.  *
  36.  *    Data buffer manip.
  37.  *
  38. $Log: pvmdabuf.c,v $
  39.  * Revision 1.4  1997/06/25  22:09:20  pvmsrc
  40.  * Markus adds his frigging name to the author list of
  41.  *     every file he ever looked at...
  42.  *
  43.  * Revision 1.3  1997/03/06  21:10:17  pvmsrc
  44.  *     quad align dabufs by adding double q[2] in alignme
  45.  *
  46.  * Revision 1.2  1997/01/28  19:27:04  pvmsrc
  47.  * New Copyright Notice & Authors.
  48.  *
  49.  * Revision 1.1  1996/09/23  23:44:31  pvmsrc
  50.  * Initial revision
  51.  *
  52.  * Revision 1.2  1994/06/03  20:38:23  manchek
  53.  * version 3.3.0
  54.  *
  55.  * Revision 1.1  1993/08/30  23:26:50  manchek
  56.  * Initial revision
  57.  *
  58.  */
  59.  
  60. #include <pvm3.h>
  61. #include "pvmalloc.h"
  62.  
  63. union alignme {
  64.     long l;
  65.     char *p;
  66.     double d;
  67.     double q[2];        /* quad-word alignment */
  68. };
  69.  
  70. #define    RCOFFSET    sizeof(union alignme)
  71.  
  72.  
  73. /***************
  74.  **  Private  **
  75.  **           **
  76.  ***************/
  77.  
  78.  
  79. char *
  80. da_new(len)
  81.     int len;
  82. {
  83.     char *p;
  84.  
  85.     if (p = TALLOC(len + RCOFFSET, char, "data")) {
  86.         p += RCOFFSET;
  87.         *(int*)(p - sizeof(int)) = 1;
  88.     }
  89.     return p;
  90. }
  91.  
  92.  
  93. void
  94. da_ref(p)
  95.     char *p;
  96. {
  97.     ++*(int*)(p - sizeof(int));
  98. }
  99.  
  100.  
  101. void
  102. da_unref(p)
  103.     char *p;
  104. {
  105.     if (--*(int*)(p - sizeof(int)) < 1)
  106.         PVM_FREE(p - RCOFFSET);
  107. }
  108.  
  109.  
  110.